<template>
  <div>
    <h2>添加</h2>
    <table class="table table-bordered">
      <tbody>
        <tr>
          <td><span style="color: red;">*</span>姓名</td>
          <td>
            <input type="text" v-model="form.name" />
          </td>
        </tr>
        <tr>
          <td>密码</td>
          <td>
            <input type="password" v-model="form.pwd" />
          </td>
        </tr>
        <tr>
          <td>等级</td>
          <td>
            <select v-model="form.dengji">
              <option value="">请选择</option>
              <option>青铜会员</option>
              <option>白银会员</option>
              <option>黄金会员</option>
            </select>
          </td>
        </tr>
        <tr>
          <td>用户名</td>
          <td>
            <input type="text" v-model="form.yongname" />
          </td>
        </tr>
        <tr>
          <td>电话</td>
          <td>
            <input type="text" v-model="form.phone" />
          </td>
        </tr>
        <tr>
          <td></td>
          <td>
            <button @click="Add">添加</button>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script setup lang="ts">
import axios from "axios";
import { onMounted, reactive, ref } from "vue";
import { useRouter } from "vue-router";
import "bootstrap/dist/css/bootstrap.min.css";

const router = useRouter();
const form = reactive({
  id: 0,
  name: "",
  pwd: "",
  dengji: "",
  yongname: "",
  phone: "",
});

const Add=()=>{
    if(!form.name){
        alert("用户名不能为空");
        return;
    }


    axios.post("https://localhost:7015/api/huiyuan/Addhui",form).then(res=>{
        if(res.data>0){
            alert("添加成功");
        }
        else{
            alert("添加失败");
            return;
        }
    })
}



</script>

<style scoped></style>
